package com.castile.console;

import arthas.VmTool;
import com.castile.common.ClassUtil;
import groovy.lang.Script;

/**
 * @description:
 * @author: Castile
 * @create: 2024-08-14 23:54
 * @Version 1.0
 **/
public abstract class ConsoleScript extends Script {

    /**
     * 获取实例
     */
    public Object[] get(Class<?> cla, Integer limit) {
        limit = limit == null ? 10 : limit;
        VmTool vmTool = ClassUtil.getVmTool();
        Object[] instances = vmTool.getInstances(cla, limit);
        return instances;
    }

    public Object[] get(Class<?> cla) {
        return get(cla, 10);
    }

}
